/*
Lori Bougher	
Title: Issue (Dis)agreement and Intergroup Bias in Affective Polarization


From proposal (revised version):

Stated-Hyp1: highlighting issue agreement will reduce affective polarization at candidate and party level
	
	Test-Hyp1: affective polarization w.r.t. outparty candidate will decrease when there is issue agreement vs. disagreement 
	
	Test-Hyp2: affective polarization w.r.t. outparty party will decrease when there is issue agreement vs. disagreement 
	
Stated-Hyp2: salience of issue will moderate relationship b/w issue agreement and negative outparty affect

	WE CANNOT TEST THIS HYPOTHESIS BECAUSE THERE IS NO EXPERIMENTAL CONDITION 
	WHERE THERE IS NON-AGREEMENT ON A NON-SALIENT ISSUE. THERE IS ONLY ONE 
	CONDITION WITH AGREEMENT AND ISSUE SALIENCE IS NOT INDICATED FOR THAT CONDITION.
	
Stated-Hyp3: strength of party attachment will not moderate the relationship b/w issue agreement and negative outparty affect and affective polarization
	
	Test-Hyp3: The relationship b/w issue agreement with outparty candidate and 
	negative outparty affect will NOT be moderated by strength of party attachment
	
	Test-Hyp4: The relationship b/w issue agreement with affective polarization and 
	negative outparty affect will NOT be moderated by strength of party attachment
	
	
NOTE: 
Hypotheses are on the last paragraph on page 3 on the proposal.

*/

clear all
use "Bougher893.dta", clear

********************************************************************************

* INDICATORS OF EXPERIMENTAL MANIPULATIONS

	* inparty or outparty [also indicates primary vs. general election]
		// control is irrelevant; recode to missing
	tab P_CUES
	recode P_CUES (1=.) (2=0) (3=1), gen(outparty)
	tab outparty, mis
	recode P_CUES (1=.) (2=0) (3=1), gen(general_election)	
	
	* alignment or non-alignment [also indicates salience]
	tab P_POLARIZE
	recode P_POLARIZE (1=1) (2/3=0), gen(issueagree)
	tab issueagree
		
	
* MODERATOR

	* salient or non-salient [only among aligned]
		tab P_POLARIZE
		recode P_POLARIZE (1=.) (2=1) (3=0), gen(salient)
		tab salient, mis
	
	* strength of group attachment: (how important is party id)
		tab Q2, mis
		clonevar imp_partyid=Q2
			* recode so higher values show increasing attachment
		recode imp_partyid (1=5) (2=4) (3=3) (4=2) (5=1)
		lab def imp 1 "not imp" 2 "slightly imp" 3 "moderately imp" ///
		4 "important" 5 "very imp"
		lab val imp_partyid imp
		replace imp_partyid=. if Q2>10
		tab imp_partyid, mis
			
* OUTCOME MEASURES
	
	* affective rating of candidate (favorable or not)
		
		* missing data
		foreach var of varlist Q5*{
		replace `var'=. if `var'>100
		}
		
		clonevar affect_candidate1=Q5A
		clonevar affect_candidate2=Q5B

	* affective rating of party
		* missing data
		foreach var of varlist Q6*{
		replace `var'=. if `var'>100
		}
	
		gen affect_dem=Q6B_0
		replace affect_dem=Q6B_1 if Q6B_0==.
		
		gen affect_rep=Q6A_0
		replace affect_rep=Q6A_1 if Q6A_0==.
		
		tab affect_dem
		tab affect_rep
		
	* affective polarization= distance b/w candidates/parties
	
		* candidate affective polarization
		gen affectpol_candidate= abs(affect_candidate1-affect_candidate2) ///
			if affect_candidate1!=. & affect_candidate2!=.
		sum affectpol_candidate
		
		* party affective polarization
		gen affectpol_party= abs(affect_dem - affect_rep) if ///
			affect_dem!=. & affect_rep!=.
		sum affectpol_party
		
		
	* R's outparty affect
		gen outparty_affect = affect_rep if partyid==1
		replace outparty_affect=affect_dem if partyid==2
		sum outparty_affect
		
	
********************************************************************************

* ANALYSIS


	*Test-Hyp1: affective polarization w.r.t. outparty candidate will decrease when there is issue agreement vs. disagreement 
	reg affectpol_candidate i.issueagree if outparty==1
		// p=0.000 
	tess 1.issueagree -, init(Bougher893) bonf(2)
	
	*Test-Hyp2: affective polarization w.r.t. outparty party will decrease when there is issue agreement vs. disagreement 
	reg affectpol_party i.issueagree if outparty==1
		// p= 0.000 
	tess 1.issueagree -, bonf(2)
	
	*Test-Hyp3: The relationship b/w issue agreement with outparty candidate and negative outparty affect will NOT be moderated by strength of party attachment
	reg outparty_affect i.issueagree##c.imp_partyid if outparty==1
		// do not reject: 0.528   => not moderated
	tess 1.issueagree#imp_partyid, bonf(2)
	
	
	*Test-Hyp4: The relationship b/w issue agreement with affective polarization and negative outparty affect will NOT be moderated by strength of party attachment
	reg affectpol_party i.issueagree##c.imp_partyid if outparty==1	
		// do not reject: 0.208 => not moderated
	tess 1.issueagree#imp_partyid, bonf(2)
